home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / gfx / show / jpegAGAsrc21.lha / jpegAGAsrc / jpegAGA / ASLScreenMode.c < prev    next >
C/C++ Source or Header  |  1995-01-14  |  2KB  |  96 lines

  1. /* Display an ASL screenmode requester */
  2. /* modified for use with jpegAGA 2.x */
  3.  
  4. #include <exec/types.h>
  5. #include <libraries/asl.h>
  6. #include <utility/tagitem.h>
  7.  
  8. #ifndef __GNUC__
  9. #include <pragmas/exec_pragmas.h>
  10. #include <pragmas/graphics_pragmas.h>
  11. #include <pragmas/asl_pragmas.h>
  12. #include <clib/exec_protos.h>
  13. #include <clib/graphics_protos.h>
  14. #include <clib/asl_protos.h>
  15. #else
  16. #include <inline/exec.h>
  17. #include <inline/graphics.h>
  18. #include <inline/asl.h>
  19. #endif
  20.  
  21. extern ULONG SMR_DisplayID;
  22. extern short SMR_HAM;
  23.  
  24. struct Library *AslBase=NULL;
  25. extern struct GfxBase *GfxBase;
  26.  
  27. struct TagItem smrtags[] = 
  28. { { ASLSM_PropertyFlags, DIPF_IS_AA}, 
  29.   { ASLSM_PropertyMask, DIPF_IS_DUALPF | DIPF_IS_EXTRAHALFBRITE}, 
  30.   { ASLSM_TitleText, 0 },
  31.   { TAG_DONE, 0 }
  32. };
  33.  
  34. int ChooseScreenMode(int grayscale, char *title)
  35. {
  36.   struct ScreenModeRequester *smr;
  37.   int ASL_failure=1;
  38.  
  39.   if(grayscale)
  40.     smrtags[1].ti_Data = DIPF_IS_DUALPF | DIPF_IS_EXTRAHALFBRITE | DIPF_IS_HAM;
  41.   else
  42.     smrtags[1].ti_Data = DIPF_IS_DUALPF | DIPF_IS_EXTRAHALFBRITE;
  43.  
  44.   smrtags[2].ti_Data = (ULONG)((void *)title);
  45.  
  46.   if(!GfxBase)
  47.   {
  48.     if(!(GfxBase = (struct GfxBase *)OpenLibrary((UBYTE *)"graphics.library",39)))
  49.     {
  50.       printf("Could not open graphics.library V39 or higher.\n");
  51.       return 1;
  52.     }
  53.   }
  54.  
  55.   if( AslBase=OpenLibrary("asl.library", 39L) )
  56.   {
  57.     if( smr = (struct ScreenModeRequester *)
  58.         AllocAslRequest(ASL_ScreenModeRequest, smrtags) )
  59.     {
  60.       if( AslRequest(smr, 0L) )
  61.       {
  62.         struct DisplayInfo queryinfo;
  63.  
  64.         /* printf("Display type: $%lx\n", smr->sm_DisplayID); */
  65.         SMR_DisplayID = smr->sm_DisplayID;
  66.         if(GetDisplayInfoData(NULL, (UBYTE *)&queryinfo, sizeof(queryinfo),DTAG_DISP,SMR_DisplayID))
  67.         {
  68.           if(queryinfo.PropertyFlags)
  69.           {
  70.             if(queryinfo.PropertyFlags & DIPF_IS_HAM)
  71.               SMR_HAM = 1;
  72.             else SMR_HAM = 0;
  73.  
  74.             /* if(SMR_HAM) printf("Mode is HAM\n"); */
  75.           }
  76.           else ASL_failure = 1;
  77.         }
  78.  
  79.         ASL_failure=0;
  80.  
  81.       }
  82.       else
  83.       {
  84.         /* printf("User cancelled or error...\n"); */
  85.         ASL_failure=1;
  86.       }
  87.  
  88.       FreeAslRequest(smr);
  89.     }
  90.     CloseLibrary(AslBase);
  91.     return ASL_failure;
  92.    }
  93.    printf("Could not open asl.library V39 or higher.\n");
  94.    return 1;
  95. }
  96.